package com.caigou.service.impl;

import com.caigou.bean.cms.entity.ArticleLawEntry;
import com.caigou.mapper.cms.ArticleLawEntryMapper;
import com.caigou.pojo.ArticleDataEntryListData;
import com.caigou.service.ArticleLawEntryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Slf4j
@Service
public class ArticleLawEntryServiceImpl implements ArticleLawEntryService {

    @Resource
    private ArticleLawEntryMapper articleLawEntryMapper;

    @Override
    public ArticleLawEntry saveArticleEntryData(Integer superId, String articleId, String entryTitle, Integer entryType) {
        ArticleLawEntry articleEntry = new ArticleLawEntry();
        articleEntry.setSuperId(superId);
        articleEntry.setArticleId(articleId);
        articleEntry.setEntryTitle(entryTitle);
        articleEntry.setEntryType(entryType);
        articleLawEntryMapper.saveArticleEntryData(articleEntry);
        return articleEntry;
    }

    @Override
    public int deleteArticleEntry(Integer id) {
        return articleLawEntryMapper.deleteArticleEntry(id);
    }

    @Override
    public int updateArticleEntry(Integer id, String label) {
        ArticleLawEntry articleEntry = new ArticleLawEntry();
        articleEntry.setId(id);
        articleEntry.setEntryTitle(label);
        return articleLawEntryMapper.updateArticleEntry(articleEntry);
    }

    @Override
    public List<ArticleDataEntryListData> loadArticleEntryList(Integer superId, String articleId) {
        return articleLawEntryMapper.loadArticleEntryList(superId,articleId);
    }

    @Override
    public ArticleLawEntry loadArticleEntry(Integer id) {
        return articleLawEntryMapper.loadArticleEntry(id);
    }

    @Override
    public List<ArticleLawEntry> loadArticleEntryBySuperId(Integer id) {
        return articleLawEntryMapper.loadArticleEntryBySuperId(id);
    }

    @Override
    public int deleteArticleEntryByArticleId(String articleId){
        return articleLawEntryMapper.deleteArticleEntryByArticleId(articleId);
    }
}
